package com.alog.yzd.bookmall.dao.admin.admin;

import com.alog.yzd.bookmall.domain.admin.admin.Admin;
import com.alog.yzd.bookmall.utils.jdbc.TxQueryRunner;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminDao {
    private QueryRunner qr = new TxQueryRunner();

    /**
     * 通过管理员名称和密码查询
     * @param adminName
     * @param adminPwd
     * @return
     * @throws SQLException
     */
    public Admin find(String adminName, String adminPwd) throws SQLException {
        String sql = "select * from t_admin where adminname = ? and adminpwd = ?";
        Admin admin = qr.query(sql, new BeanHandler<Admin>(Admin.class), new Object[]{adminName, adminPwd});
        return admin;
    }

}
